package edu.netjava.jdbc;

import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class MysqlJdbcConnectorTest {
	
	
	public static void main(String[] args){
		
		try {
			Class.forName("com.mysql.jdbc.Driver");
			java.sql.Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/student","root","netjava");
	
			Statement sta = con.createStatement();
			
			String sql = "SELECT * FROM INFOVIEW";
			
			ResultSet rs = sta.executeQuery(sql);
			
			while(rs.next()){
				
				for(int i = 1;i<=4;i++){
					
					System.out.print(rs.getString(i)+"\t");
					
					
				}
				
				System.out.println();
				
				
				
			}
			
			String sql2 = "insert into info values(12,'lilde',20,'math')";
			
			sta.execute(sql2);
			
			sql = "SELECT * FROM INFOVIEW";
			
			rs = sta.executeQuery(sql);
			
			while(rs.next()){
				
				for(int i = 1;i<=4;i++){
					
					System.out.print(rs.getString(i)+"\t");
					
					
				}
				
				System.out.println();
				
				
				
			}
			
			
			
			
		} catch (Exception e) {
				e.printStackTrace();
		}
		
		
	}
	
	
	
	

}
